import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter);
export const asyncRouteMap = [
  {
    path: "/home",
    name: "home",
    component: () =>
    import(
      "../components/data/index.vue"
    ),
    meta: {
      requiresAuth: true,
      title: '首页',
      index: '1'
    },
  },
  //账户管理

  {
    path: "/accountList",
    name: "accountList",
    component: () =>
      import(
        "../views/account/AccountList.vue"
      ),
    meta: {
      requiresAuth:false,
      title: '账户列表',
      index: '2'
    }
  },
  {
    path: "/role",
    name: "role",
    component: () =>
      import(
        "../views/account/Role.vue"
      ),
    meta: {
      requiresAuth:false,
      title: '角色管理',
      index: '2'
    }
  },
  //用户列表
  {
    path: "/exhibitors",
    name: "exhibitors",
    component: () =>
      import(
        "../views/user/Exhibitors.vue"
      ),
    meta: {
      title: '展商报名列表',
      index: '3'
    }
  },
  {
    path: "/audience",
    name: "audience",
    component: () =>
      import("../views/user/Audience.vue"),
    meta: {
      title: '观众报名列表',
      index: '3'
    }
  },
  {
    path: "/exhibition",
    name: "exhibition-index",
    component: () =>
      import("../views/exhibition/index.vue"),
    meta: {
      title: '展会概况',
      index: '4'
    },
    children:[
      {
        path: "/exhibition",
        name: "exhibition",
        component: () =>
          import("../views/exhibition/Exhibition.vue"),
        meta: {
          title: '展会列表',
          index: '4'
        }
      },
      {
        path: "/exhibition/schedule",
        name: "schedule",
        component: () =>
          import("../views/exhibition/Schedule.vue"),
        meta: {
          title: '展会日程',
          index: '4'
        }
      },
      {
        path: "/exhibition/units",
        name: "units",
        component: () =>
          import("../views/exhibition/Units.vue"),
        meta: {
          title: '组织单位',
          index: '4'
        }
      },
    ]
  },
  {
    path: "/exhibition/classification",
    name: "classification",
    component: () =>
      import("../views/exhibition/Classification.vue"),
    meta: {
      title: '文章分类',
      index: '4'
    }

  },
  {
    path: "/exhibition/ArticleList",
    name: "ArticleList",
    component: () =>
      import("../views/exhibition/ArticleList.vue"),
    meta: {
      title: '文章列表',
      index: '4'
    }

  },
  {
    path: "/exhibition/New",
    name: "New",
    component: () =>
      import("../views/exhibition/New.vue"),
    meta: {
      title: '微信图文素材列表',
      index: '4'
    }

  },
  {
    path: "/meeting",
    name: "Meeting",
    component: () =>
      import("../views/meeting/index.vue"),
    meta: {
      title: '会议列表',
      index: '5'
    }
  },
  {
    path: "/activities",
    name: "Activities",
    component: () =>
      import("../views/Supporting-activities/index.vue"),
    meta: {
      title: '配套活动列表',
      index: '6'
    }
  },
  {
    path: "/partners",
    name: "Partners",
    component: () =>
      import("../views/partners/index.vue"),
    meta: {
      title: '合作伙伴列表',
      index: '7'
    }
  },
  {
    path: "/Partner-class",
    name: "Partner-class",
    component: () =>
      import("../views/partners/class.vue"),
    meta: {
      title: '合作伙伴分类',
      index: '7'
    }
  },
  {
    path: "/Service-team",
    name: "Service-team",
    component: () =>
      import("../views/Service-team/index.vue"),
    meta: {
      title: '服务团队列表',
      index: '8'
    }
  },
  {
    path: "/Exhibitor-list",
    name: "Exhibitor-list",
    component: () =>
      import("../views/Exhibitor-list/index.vue"),
    meta: {
      title: '展商名录列表',
      index: '9'
    }
  },
  {
    path: "/Exhibitor-list/Ostentatious-enquiries",
    name: "Ostentatious-enquiries",
    component: () =>
      import("../views/Exhibitor-list/Ostentatious-enquiries.vue"),
    meta: {
      title: '招商询盘列表',
      index: '9'
    }
  },
  {
    path: "/system-log",
    name: "system-log",
    component: () =>
      import("../views/system-log/index.vue"),
    meta: {
      title: '系统操作日志',
      index: '10'
    }
  },
  {
    path: "/weapp-log",
    name: "weapp-log",
    component: () =>
      import("../views/system-log/weapp-log.vue"),
    meta: {
      title: '小程序用户日志',
      index: '10'
    }
  },
  {
    path: "/WxUser",
    name: "WxUser",
    component: () =>
      import("../views/user/WxUser.vue"),
    meta: {
      title: '小程序用户',
      index: '11'
    }
  },
  {
    path: "/news/New-release",
    name: "News",
    component: () =>
      import("../views/News/News.vue"),
    meta: {
      title: '新闻发布',
      index: '5'
    },
    children: [
      {
        path: "/news/New-release",
        name: "New-release",
        component: () =>
          import("../views/News/New-release.vue"),
        meta: {
          title: '新闻发布',
          index: '5'
        },
        children: [

        ]
      },
      {
        path: "/news/New-edit",
        name: "New-edit",
        component: () =>
          import("../views/News/New-edit.vue"),
        meta: {
          title: '新闻编辑',
          index: '5'
        },
      }
    ]
  },
  {
    path: "/news/Media-cooperation",
    name: "News",
    component: () =>
      import("../views/News/News.vue"),
    meta: {
      title: '媒体合作',
      index: '5'
    },
    children: [
      {
        path: "/news/Media-cooperation",
        name: "Media-cooperation",
        component: () =>
          import("../views/News/Media-cooperation.vue"),
        meta: {
          title: '媒体合作',
          index: '5'
        },
        children: [

        ]
      },
      {
        path: "/news/Media-edit",
        name: "Media-edit",
        component: () =>
          import("../views/News/New-edit.vue"),
        meta: {
          title: '新闻编辑',
          index: '5'
        },
      }
    ]
  },
]
export const routes  = [
  {
    path: '/',
    name: 'login',
    component: () => import('../views/Login.vue'),
    meta: {
      title: '登录'
    }
  },
  {
    path: "/404",
    name: "notFound",
    component: () => import('../components/NotFound.vue'),
    meta: {
      title: '找不到页面'
    }
  },
  {
    path: "/permissions",
    name: "permissions",
    component: () => import('../components/Permissions.vue'),
    meta: {
      title: '无权限'
    }
  },
  { path: "*", redirect: "/404", hidden: true },
  {
    path:'/',
    redirect: "/home",
    component: Home,
    meta: {
      requiresAuth: true,
      title: '首页',
      index: '1'
    },
    children: [
      ...asyncRouteMap
    ],
  },
];


const router =  new VueRouter({
  routes
})
export default router;
